import request from '@/config/axios'
interface EmergencyContactType {
  username: string
  mobile: number | string
  relation: string
}
interface FamilyMembersType {
  familyName: string
  familySex: string
  familyRelation: string
  familyIdNumber: string //身份证
  workOrganization: string //工作单位
  workPost: string //职务
  address: string //地点
}
interface EducationExperienceType {
  schoolName: string
  schoolAddress: string //地点
  education: string //学历
  isFullTime: Boolean //是否全日制
  profession: string //专业
  entranceDate?: string //入学时间
  graduateDate?: string //毕业时间
  certificate: string //证书
}
interface WorkExperienceType {
  companyName: string //单位名称
  companyDepart: string //部门
  companyPost: string //岗位
  companyAddress: string //工作地址
  companyVoucher: string //单位证明人
  companyVoucherTelphone: string //单位证明人电话

  certificate: string //证书
  entryDate: string //入职日期
  dimissionDate: string //离职日期
}

export interface UserVO {
  sourceTenantName?: any
  id?: number
  mobile: string //手机
  username: string //登录账号
  familyName: string //真实姓名
  jobNumber?: string //员工工号
  nickname: string //昵称
  sex: number //性别
  education: string //学历
  email: string //邮箱
  marital: string //婚姻
  idNum: string //身份证
  userBirthday?: Date //生日
  userAge: string //年龄
  userNationalities: string //民族
  userPolitical?: string //政治面貌
  userSource?: string //来源
  avatar: string //头像
  bareheaded: string //免冠照
  deptId: number | string //部门
  postIds: string[] //岗位，
  postType: EmptyArrayType //岗位类型
  entryDate: string //入职日期
  officialDate: string //转正日期
  dimissionDate: string //离职日期
  password?: string //密码
  // 户籍信息
  houseCity: string //户口所在地
  houseAddress: string //户口所在地地址
  liveCity: string //现居地
  liveAddress: string //现居地地址
  // 紧急联系人
  usersLinkmanSaveReqVOList: EmergencyContactType[] //紧急联系人
  // 家庭成员
  usersFamilySaveReqVOList: FamilyMembersType[]
  // 教育经历
  usersEducationSaveReqVOList: EducationExperienceType[]
  // 工作经历
  usersExperienceSaveReqVOList: WorkExperienceType[]
  // 岗位权限
  tenantRelevancys: EmptyArrayType[]
  loginIp?: string
  status?: number //状态
  userStatus?: number //员工状态
  remark?: string //备注
  loginDate?: Date
  createTime?: Date
  proportion?: number //业绩分成比例
  tenantAdmin?: number
}

// 查询用户管理列表
export const getUserPage = (params: PageParam) => {
  return request.get({ url: '/system/user/page', params })
}

// 查询所有用户列表
export const getAllUser = () => {
  return request.get({ url: '/system/user/all' })
}

// 查询用户详情
export const getUser = (id: number) => {
  return request.get({ url: '/system/user/get?id=' + id })
}

// 新增用户
export const createUser = (data: UserVO) => {
  return request.post({ url: '/system/user/create', data })
}

// 修改用户
export const updateUser = (data: UserVO) => {
  return request.put({ url: '/system/user/update', data })
}

// 删除用户
export const deleteUser = (id: number) => {
  return request.delete({ url: '/system/user/delete?id=' + id })
}

// 导出用户
export const exportUser = (params) => {
  return request.download({ url: '/system/user/export', params })
}

// 下载用户导入模板
export const importUserTemplate = () => {
  return request.download({ url: '/system/user/get-import-template' })
}

// 用户密码重置
export const resetUserPwd = (id: number, password: string) => {
  const data = {
    id,
    password
  }
  return request.put({ url: '/system/user/update-password', data: data })
}

// 用户状态修改
export const updateUserStatus = (id: number, status: number) => {
  const data = {
    id,
    status
  }
  return request.put({ url: '/system/user/update-status', data: data })
}

// 获取用户精简信息列表
export const getSimpleUserList = (): Promise<UserVO[]> => {
  return request.get({ url: '/system/user/simple-list' })
}
// 获取用户已绑定租户列表
export const getAccountBindTenantList = (params): Promise<any> => {
  return request.get({ url: '/system/user/getAccountBindTenantList', params })
}
// 验证手机号
export const getValidationMobile = (params) => {
  return request.get({ url: '/system/user/validationMobile', params })
}
